<template>
  <div class="assessment-edit-plan-container">
    <div class="my-form-container">
      <el-row
        class="my-form-item"
      >
        <el-col :span="12">
          <div class="my-form-item-label">课程名称</div>
          <div class="my-form-item-value">
            <span>{{tablelist.coursename}}</span>
          </div>
        </el-col>
        <el-col :span="12">
          <div class="my-form-item-label">课程编号</div>
          <div class="my-form-item-value">
            <span>{{tablelist.coursenumber}}</span>
          </div>
        </el-col>
      </el-row>
      <el-row class="my-form-item">
        <el-col :span="12">
          <div class="my-form-item-label">课程类型</div>
          <div class="my-form-item-value">
            <span>{{tablelist.coursetype}}</span>
          </div>
        </el-col>
        <el-col :span="12">
          <div class="my-form-item-label">学时</div>
          <div class="my-form-item-value">
            <span>{{tablelist.classhour}}</span>
          </div>
        </el-col>
      </el-row>
      <el-row class="my-form-item">
        <el-col :span="12">
          <div class="my-form-item-label">学分</div>
          <div class="my-form-item-value">
            <span>{{tablelist.credithour}}</span>
          </div>
        </el-col>
        <el-col :span="12">
          <div class="my-form-item-label">培养层次</div>
          <div class="my-form-item-value">
            <span>{{tablelist.traininglevel}}</span>
          </div>
        </el-col>
      </el-row>
      <el-row class="my-form-item">
        <el-col :span="12">
          <div class="my-form-item-label">分制</div>
          <div class="my-form-item-value">
            <!-- @input="handleChangeZY" -->
            <el-select
              v-model="tablelist.scoretypecode"
              placeholder="请选择"
              clearable
              @input="handleChangeZY"
              style="width:130px"
            >
              <el-option
                v-for="item in scoreList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </div>
        </el-col>
        <el-col :span="12">
          <div class="my-form-item-label">课程考核一票否决</div>
          <div class="my-form-item-value">
            <span>{{tablelist.oneticketveto}}</span>
          </div>
        </el-col>
      </el-row>
      <el-row class="my-form-item">
        <el-col :span="12">
          <div class="my-form-item-label">授课对象</div>
          <div class="my-form-item-value">
            <span>{{tablelist.professionaldivisions}}</span>
          </div>
        </el-col>
        <el-col :span="12">
          <div class="my-form-item-label">人数</div>
          <div class="my-form-item-value">
            <span>{{tablelist.totalnumber}}</span>
          </div>
        </el-col>
      </el-row>
      <el-row class="my-form-item">
        <el-col :span="12">
          <div class="my-form-item-label">开课教研室</div>
          <div class="my-form-item-value">
            <span>{{tablelist.teachingandresearchsection}}</span>
          </div>
        </el-col>
        <el-col :span="12">
          <div class="my-form-item-label">教学班数</div>
          <div class="my-form-item-value">
            <span>{{tablelist.classsize}}</span>
          </div>
        </el-col>
      </el-row>
      <el-row class="my-form-item">
        <el-col :span="12">
          <div class="my-form-item-label">课程负责人</div>
          <div class="my-form-item-value">
            <span>{{tablelist.coursemanager}}</span>
          </div>
        </el-col>
        <el-col :span="12">
          <div class="my-form-item-label">授课教员</div>
          <div class="my-form-item-value">
            <span>{{tablelist.teachingfaculty}}</span>
          </div>
        </el-col>
      </el-row>
      <el-row class="my-form-item">
        <el-col :span="12">
          <div class="my-form-item-label">课下作业成绩所占比例</div>
          <div class="my-form-item-value">
            <el-input type="number" v-model="tablelist.usualscorerate" style="width:130px" /> % 
            <!-- <span>{{tablelist.}}%</span> -->
          </div>
        </el-col>
        <el-col :span="12">
          <div class="my-form-item-label">课堂测试成绩所占比例</div>
          <div class="my-form-item-value">
            <el-input type="number" v-model="tablelist.examscorerate" style="width:130px"  /> % 
            <!-- <span>{{tablelist.}}%</span> -->
          </div>
        </el-col>
      </el-row>
      <el-row class="my-form-item">
        <el-col :span="12">
          <div class="my-form-item-label">期中考试成绩所占比例</div>
          <div class="my-form-item-value">
            <el-input type="number" v-model="tablelist.midtermscorerate" style="width:130px"  /> % 
          </div>
        </el-col>
        <el-col :span="12">
          <div class="my-form-item-label">期末考试成绩所占比例</div>
          <div class="my-form-item-value">
            <!-- <span>{{tablelist.experimentscoreratealter}}%</span> -->
            <el-input type="number" v-model="tablelist.experimentscorerate" style="width:130px"  />% 
          </div>
        </el-col>
      </el-row>
      <el-row class="my-form-item">
        <el-col :span="12">
          <div class="my-form-item-label">期末考试方式</div>
          <div class="my-form-item-value">
            <el-select
              v-model="tablelist.finalexamination"
              placeholder="请选择"
              clearable
              @input="handleChangeZY"
              style="width:130px"
            >
              <el-option
                v-for="item in finalexamList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
            <!-- <el-input v-model="tablelist.finalexamination" style="width:100px"  /> -->
            <!-- <span>{{tablelist.finalexaminationalter}}%</span> -->
          </div>
        </el-col>
        <el-col :span="12">
          <div class="my-form-item-label">场地需求</div>
          <div class="my-form-item-value">
            <el-select
              v-model="tablelist.situdemand"
              placeholder="请选择"
              size="small"
              style="width: 187px"
            >
              <el-option
                v-for="(item,index) in classrooms"
                :key="index"
                :label="item.cdmc"
                :value="item.cdmc"
              >
              </el-option>
            </el-select>
          </div>
        </el-col>
      </el-row>
      <el-row class="my-form-item" style="height: 278px; border: none">
        <el-col :span="24">
          <div class="my-form-item-label">考核设计</div>
          <div class="my-form-item-value assessment-design">
            <el-input
              v-model="tablelist.assessmentdesign"
              type="textarea"
              :rows="9"
              style="width: 969px"
              placeholder="请输入内容"
            ></el-input>
          </div>
        </el-col>
      </el-row>
    </div>
    <div class="button-group">
      <div @click="updateCouPlan">保 存</div>
      <div @click="updateSubmitCouPlan">保存并提交</div>
      <div @click="cancalS">取 消</div>
    </div>
  </div>
</template>

<script>
import {getDetailD, update, updateSubmit} from "../../../api/courseExame/courseExa";
import tablelistVue from '../../comonents/tablelist.vue';
import { getStore } from '@/util/store.js'
import { getPlaceInfoList} from "@/api/courseAchievement/entryResults";

export default {
  data() {
    return {
      design: "",
      tableData: [],
      tablelist:{},
      scoreList: [
        {
          value: "百分制",
          label: "百分制"
        },
        {
          value: "四分制",
          label: "四分制"
        },
        {
          value: "五分制",
          label: "五分制"
        },
        {
          value: "二分制",
          label: "二分制"
        }
      ],
      finalexamList: [
        {
          value: "笔试闭卷",
          label: "笔试闭卷"
        },
        {
          value: "笔试开卷",
          label: "笔试开卷"
        },
        {
          value: "口试",
          label: "口试"
        },
        {
          value: "机试",
          label: "机试"
        },
        {
          value: "实操",
          label: "实操"
        },
        {
          value: "课程论文",
          label: "课程论文"
        },
        {
          value: "其他",
          label: "其他"
        }
      ],
      // detailList:{},
      roleId:'',
      classrooms:[]
    };
  },
  created() {
    const userInfo = getStore({
      name: "userInfo",
      debug: true,
    }) || {}
    this.roleId = userInfo.content.role_id;
    this.getPlaceInfo();
    this.tablelist = this.$route.query.planid;
    // getDetailD(this.tablelist.modifyid).then(res=>{
    //   this.detailList = res.data.data;
    // })
  },
  methods: {
    getPlaceInfo(){ 
      getPlaceInfoList(this.cdmc,this.ssjzw,this.zwsTop,this.zwsLow).then(res=>{
        if(res.data.code == 200){
          this.classrooms = res.data.data
        }
      })
    },
    // 取消
    cancalS() {
      if(this.roleId === '1475294432243830786'){
        this.$router.push({
          path: "/teacher/assessment/plan",
        });
      } else if(this.roleId === '1490880658945843202'){
        this.$router.push({
          path: "/director/planManagement/planag",
        })
      } else if(this.roleId === '1490859421955674114'){
        this.$router.push({
          path: "/admin/planManagement/Print",
        })
      }
    },
    //保存
    updateCouPlan() {
      let obj = {
        planid: this.tablelist.planid,
        scoretypecode: this.tablelist.scoretypecode,
        usualscorerate:this.tablelist.usualscorerate,  
        examscorerate:this.tablelist.examscorerate,  
        midtermscorerate:this.tablelist.midtermscorerate,  
        experimentscorerate:this.tablelist.experimentscorerate,
        finalexamination:this.tablelist.finalexamination, 
        situdemand:this.tablelist.situdemand, 
        assessmentdesign:this.tablelist.assessmentdesign, 
      }
      update(obj).then(res => {
        if(res.data.code == 200){
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          if(this.roleId === '1475294432243830786'){
            this.$router.push({
              path: "/teacher/assessment/plan",
            });
          } else if(this.roleId === '1490880658945843202'){
            this.$router.push({
              path: "/director/planManagement/planag",
            })
          } else if(this.roleId === '1490859421955674114'){
            this.$router.push({
              path: "/admin/planManagement/Print",
            })
          }
        }
      })
    },
    //保存并提交
    updateSubmitCouPlan() {
      this.updateCouPlan();
      updateSubmit(this.tablelist.planid, this.roleId).then(res => {
        if(res.data.code == 200){
          // this.$message({
          //   type: "success",
          //   message: "操作成功!",
          // });
          if(this.roleId === '1475294432243830786'){
            this.$router.push({
              path: "/teacher/assessment/plan",
            });
          } else if(this.roleId === '1490880658945843202'){
            this.$router.push({
              path: "/director/planManagement/planag",
            })
          } else if(this.roleId === '1490859421955674114'){
            this.$router.push({
              path: "/admin/planManagement/Print",
            })
          }
        }
      })
    },
    open(str) {
      this.$confirm(str, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "保存成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消保存",
          });
        });
    },
  },
};
</script>
<style lang="less" scoped>
/deep/.my-form-item-value{
  padding: 0 38px;
}
.assessment-edit-plan-container {
  .assessment-design {
    .el-textarea__inner {
      resize: none;
      font-size: 16px;
      color: rgba(0, 76, 167, 1);
    }
  }
}
</style>
<style scoped lang="less">
  .button-group {
    cursor: pointer;
    text-align: center;

    > div {
      display: inline-block;
      font-size: 18px;
      padding: 6px 22px;
      border-radius: 6px;

      &:nth-child(1) {
        color: #f3b815;
        border: 1px solid #f3b815;
        background: #fff6ef;
        margin-right: 89px;
      }

      &:nth-child(2) {
        color: #02c86c;
        border: 1px solid #02c86c;
        background: #f1fff8;
        margin-right: 89px;
      }
      &:nth-child(3) {
        color: #ff3819;
        border: 1px solid #ff3819;
        background: #ffefef;
      }
    }
  }
.assessment-edit-plan-container {
  .assessment-design {
    padding: 25px 38px !important;

    .el-textarea__inner {
      resize: none;
    }

    .red-tip {
      margin: 0 7px;
      display: inline-block;
      vertical-align: 105px;
    }
  }

}

/deep/ .el-input--medium .el-input__inner {
  border: 1px solid #f9f9f9;
  background-color: #f9f9f9;
  width: 30%;
  margin-left: -12px !important;
}

</style>
